﻿#define _CRT_SECURE_NO_WARNINGS 1
#define max(a,b)((a)>(b)?(a):(b))//宏
#include<stdio.h>


int MAX(int a, int b)
{
	return ((a) > (b) ? (a) : (b));
}
int main1()
{
	int x = 5;
	int y = 6;
	int z=MAX(x, y);//函数
	//int z=max(x, y);//宏
	printf("%d ", z);
	return 0;
}




//什么事情宏能做到，但函数做不到？
#define MALLOC(num, type) (type*)malloc(num*sizeof(type))
int main12()
{
	//使⽤
	int* p = MALLOC(10, int);//类型作为参数
	//预处理器替换之后：
	(int)malloc(10,sizeof(int));
	return 0;
}

//#运算符
#define Print(n,format) printf("the value of "#n" is "format"\n",n)
                                            //"a"

int main3()
{
	int a = 10;
	Print(a, "%d");
	return 0;
}


//##运算符
#define GENRIC_MAX(type)\
type type##_max(type x,type y)\
{\
	return x>y?x:y;\
}	
GENRIC_MAX(int) 
GENRIC_MAX(float)

int main111()
{
	int a = 10;
	int b = 21;
	int ret = int_max(a, b);
	printf("%d ",ret);

	float i = 1.2;
	float j = 2.1;
	float rett = float_max(i,j);
	printf("%f ",rett);

	return 0;
}







